Pathnames

KCL provides a # macro #" that reads a pathname: #"string" is equivalent to ( apathname "string") . For example,

          #"foo.lsp"

is equivalent to

          (pathname "foo.lsp").

The same format is used when a pathname is printed.


The initial value of the Common Lisp variable &sstarf#star;default-pathname-defaults&sstarf#star; is #"" (or, equivalently, (pathname "") ).


A pathname in the file system of Common Lisp consists of the following six elements:

          host  device  directory  name  type  version

Among these elements, KCL does not use host, device, and version. That is, when converting a namestring into a pathname, KCL turns these three elements into nil. Conversely, when converting a pathname into a namestring, KCL ignores these three elements.


In the sequel, we explain how KCL converts a namestring into a pathname.


If a namestring contains one or more periods `.', the last period separates the namestring into the file name and the filetype.

     "foo.lsp"
         name:          "foo" 
         type:          "lsp"

     "a.b.c" 
         name:          "a.b" 
         type:          "c"

If a namestring ends with a period, the filetype becomes the null string.

     "foo." 
          name:          "foo" 
          type:          ""  (null string)

If a namestring begins with a period, the file name becomes nil .

     ".lsp" 
          name:          nil 
          type:          "lsp"

If a namestring contains no period, the filetype is nil .

    "foo" 
          name:          "foo" 
          type:          nil

In a pathname, the file directory is represented as a list.

     "common/demo/foo.lsp" 
          directory:     ("common"   "demo") 
          name:          "foo" 
          type:          "lsp"

If a namestring does not contain a directory, the directory component of the pathname is nil .

     "foo.lsp" 
          directory:     nil 
          name:          "foo" 
          type:          "lsp"

In a pathname, the root directory is represented by the keyword :root.

     "/usr/common/foo.lsp"
          directory:     (:root "usr" "common") 
          name:          "foo" 
          type:          "lsp"

The abbreviation symbols ` . ' and ` .. ' may be used in a namestring.

     "./demo/queen.lsp" 
          directory:     (:current\(ri ':current) "demo") 
          name:          "queen" 
          type:          "lsp" 

     "../../demo/queen.lsp" 
          directory:     (:parent\(ri ':parent) :parent "demo") 
          name:          "queen" 
          type:          "lsp"

:current and :parent represent the current directory and the parent directory, respectively.


The part of a namestring after the last slash `/' is always regarded as representing the file name and the filetype. In order to represent a pathname with both the name and the filetype nil, end the pathname with a slash.

     "/usr/common/" 
          directory:     (:root "usr" "common") 
          name:          nil 
          type:          nil 

     "/usr/common/.lsp" 
          directory:     (:root "usr" "common") 
          name:          nil 
          type:          "lsp"

` * ' in the place of file name or filetype becomes :wild

     "*.lsp" 
          name:          :wild 
          type:          "lsp" 

     "foo.*" 
          name:          "foo" 
          type:          :wild

———- Note to KCL/AOS users ————

In KCL/AOS, all the lower-case letters are turned into upper-case letters by pathname conversions. Thus, for example,

     "foo.lsp" 
          name:          "FOO" 
          type:          "LSP"

KCL/AOS follows the convention of the AOS/VS file system: The symbols `/ ', ` . ', ` .. ', and ` * ' in the examples above should be replaced by ` : ', ` = ', ` ˆ', and ` - ', respectively, in KCL/AOS.



————— End of Note —————